using Curriculum.Services;

namespace ConcursoCV.UI.WebUserControls.Inscripcion
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	/// <summary>
	///		Summary description for ConcursoInscripcion.
	/// </summary>
	public class ConcursoInscripcion : System.Web.UI.UserControl
	{
		protected Pluspetrol.Core.UIControls.WebControls.ConfirmButton btnInscribir;
		protected System.Web.UI.WebControls.Button btnCancelar;
		protected WebUserControls.Concurso.ABMConcursos ucABMConcursos;

		private const string pidConcursoInscripcion = "013";
		

		private void Page_Load(object sender, System.EventArgs e)
		{
			if( !this.IsPostBack )
			{
				this.ConcursoId = this.Request["concursoId"];
				this.DocenteId = this.Request["docenteId"];
				if( this.Request["tipo"] == "INSCRIPTO")
				{
					this.btnInscribir.Visible = false;	
				}					
				this.ucABMConcursos.btnAceptarVisible = false;
				this.ucABMConcursos.btnCancelarVisible = false;				
			}
		}

		private void Redirect()
		{
			string url = "Default.aspx?pid=" + pidConcursoInscripcion;
			Server.Transfer(url);
		}

		#region - Properties -

		private string ConcursoId
		{
			get{ return (string) ViewState["_concursoId"];}
			set{ ViewState["_concursoId"] = value;}
		}
		private string DocenteId
		{
			get{ return (string) ViewState["_docenteId"];}
			set{ ViewState["_docenteId"] = value;}
		}

		#endregion - Properties -

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnInscribir.Click += new System.EventHandler(this.btnInscribir_Click);
			this.btnCancelar.Click += new System.EventHandler(this.btnCancelar_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnInscribir_Click(object sender, System.EventArgs e)
		{
			ConcursoService svc = new ConcursoService();
			svc.InscribirDocente( ConcursoId, DocenteId );
			Redirect();
		}

		private void btnCancelar_Click(object sender, System.EventArgs e)
		{
			Redirect();
		}
	}
}
